/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.beans.address;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author alina
 */
@Stateless
public class AddressEntityFacade implements AddressEntityFacadeRemote {
    @PersistenceContext
    private EntityManager em;
	

	public AddressEntity addAddress(int addressType,int streetNum,String streetName,int buildingNum,int floorNum,int apartmentNum,String zipcode,String city){

        AddressEntity address = new AddressEntity();
		
	    address.setAddressType(addressType);
		address.setStreetNum(streetNum);
		address.setStreetName(streetName);
		address.setBuildingNum(buildingNum);
		address.setFloorNum(floorNum);
		address.setApartmentNum(apartmentNum);
		address.setZipcode(zipcode);
		address.setCity(city);
        
        em.persist(address);
        
        return address;
   
    }
	public void persistAddress(AddressEntity address){
		/*
        AddressEntity newAddress = new AddressEntity();
		
	    newAddress.setAddressType(address.getAddressType());
	    newAddress.setStreetNum(address.getStreetNum());
	    newAddress.setStreetName(address.getStreetName());
	    newAddress.setBuildingNum(address.getBuildingNum());
	    newAddress.setFloorNum(address.getFloorNum());
	    newAddress.setApartmentNum(address.getApartmentNum());
	    newAddress.setZipcode(address.getZipcode());
	    newAddress.setCity(address.getCity());
        */
        em.persist(address);
    }
	
	
	
}